package rohyunji;

import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JLabel;

import java.awt.Button;
import java.awt.CardLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;

import javax.swing.JTextField;

import javax.swing.JRadioButton;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.BorderLayout;

import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;

import java.util.Date;
import java.util.Calendar;
import java.awt.Choice;

import javax.swing.SpinnerNumberModel;

import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

import javax.swing.JEditorPane;
import javax.swing.JTextArea;

public class CreateAnnounce extends JPanel {
	private JTextField ac_text;
	private JTextField cr_year1_text;
	private JTextField ac_final;
	private JTextField ac_start;
	private AnnounceVO av;
	private int type=0;
	public CreateAnnounce(final CardLayout menu2AreaCard, final JPanel menuArea2,final CardLayout rightCard,final JPanel right_area) {
		setLayout(new BorderLayout(0, 0));
		
		av=new AnnounceVO();
		JPanel panel = new JPanel();
		add(panel, BorderLayout.CENTER);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[]{10, 0, 61, 0, 50, 15, 55, 0, 50, 0,0};
		gbl_panel.rowHeights = new int[]{20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 0};
		gbl_panel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		panel.setLayout(gbl_panel);
		
		JLabel label = new JLabel("공고제목");
		GridBagConstraints gbc_label = new GridBagConstraints();
		gbc_label.fill = GridBagConstraints.HORIZONTAL;
		gbc_label.insets = new Insets(0, 0, 5, 5);
		gbc_label.gridx = 1;
		gbc_label.gridy = 1;
		panel.add(label, gbc_label);
		
		ac_text = new JTextField();
		ac_text.setColumns(30);
		GridBagConstraints gbc_ac_text = new GridBagConstraints();
		gbc_ac_text.fill = GridBagConstraints.BOTH;
		gbc_ac_text.gridwidth = 7;
		gbc_ac_text.insets = new Insets(0, 0, 5, 5);
		gbc_ac_text.gridx = 2;
		gbc_ac_text.gridy = 1;
		panel.add(ac_text, gbc_ac_text);
		
		JLabel label_1 = new JLabel("기업이름");
		GridBagConstraints gbc_label_1 = new GridBagConstraints();
		gbc_label_1.insets = new Insets(0, 0, 5, 5);
		gbc_label_1.gridx = 1;
		gbc_label_1.gridy = 3;
		panel.add(label_1, gbc_label_1);
		
		
		JLabel ac_name_lbl = new JLabel("New label");
		GridBagConstraints gbc_ac_name_lbl = new GridBagConstraints();
		gbc_ac_name_lbl.gridwidth = 3;
		gbc_ac_name_lbl.fill = GridBagConstraints.HORIZONTAL;
		gbc_ac_name_lbl.insets = new Insets(0, 0, 5, 5);
		gbc_ac_name_lbl.gridx = 2;
		gbc_ac_name_lbl.gridy = 3;
		panel.add(ac_name_lbl, gbc_ac_name_lbl);
		ac_name_lbl.setText("ㅇ");
		ButtonGroup radios=new ButtonGroup();
		JRadioButton ac_type = new JRadioButton("신입");
		
		GridBagConstraints gbc_ac_type = new GridBagConstraints();
		gbc_ac_type.fill = GridBagConstraints.VERTICAL;
		gbc_ac_type.insets = new Insets(0, 0, 5, 5);
		gbc_ac_type.gridx = 2;
		gbc_ac_type.gridy = 4;
		panel.add(ac_type, gbc_ac_type);
		radios.add(ac_type);
		JRadioButton ac_typeC = new JRadioButton("경력");
	
		GridBagConstraints gbc_ac_typeC = new GridBagConstraints();
		gbc_ac_typeC.fill = GridBagConstraints.VERTICAL;
		gbc_ac_typeC.insets = new Insets(0, 0, 5, 5);
		gbc_ac_typeC.gridx = 3;
		gbc_ac_typeC.gridy = 4;
		panel.add(ac_typeC, gbc_ac_typeC);
		radios.add(ac_typeC);
		
		cr_year1_text = new JTextField();
		cr_year1_text.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		cr_year1_text.setColumns(20);
		GridBagConstraints gbc_cr_year1_text = new GridBagConstraints();
		gbc_cr_year1_text.fill = GridBagConstraints.BOTH;
		gbc_cr_year1_text.insets = new Insets(0, 0, 5, 5);
		gbc_cr_year1_text.gridx = 4;
		gbc_cr_year1_text.gridy = 4;
		panel.add(cr_year1_text, gbc_cr_year1_text);
		cr_year1_text.setVisible(false);
		
		final JLabel label_4 = new JLabel("년 이상");
		GridBagConstraints gbc_label_4 = new GridBagConstraints();
		gbc_label_4.fill = GridBagConstraints.VERTICAL;
		gbc_label_4.anchor = GridBagConstraints.EAST;
		gbc_label_4.insets = new Insets(0, 0, 5, 5);
		gbc_label_4.gridx = 5;
		gbc_label_4.gridy = 4;
		panel.add(label_4, gbc_label_4);
		label_4.setVisible(false);
		
		
		JLabel label_3 = new JLabel("모집학력");
		GridBagConstraints gbc_label_3 = new GridBagConstraints();
		gbc_label_3.anchor = GridBagConstraints.EAST;
		gbc_label_3.insets = new Insets(0, 0, 5, 5);
		gbc_label_3.gridx = 1;
		gbc_label_3.gridy = 5;
		panel.add(label_3, gbc_label_3);
		
		JLabel label_6 = new JLabel("모집경력");
		GridBagConstraints gbc_label_6 = new GridBagConstraints();
		gbc_label_6.fill = GridBagConstraints.VERTICAL;
		gbc_label_6.insets = new Insets(0, 0, 5, 5);
		gbc_label_6.gridx = 1;
		gbc_label_6.gridy = 4;
		panel.add(label_6, gbc_label_6);
		
		JComboBox cmb_el = new JComboBox();
		cmb_el.setModel(new DefaultComboBoxModel(new String[] {"학력무관", "고졸", "전졸", "대졸", "석사", "박사"}));
		GridBagConstraints gbc_cmb_el = new GridBagConstraints();
		gbc_cmb_el.gridwidth = 2;
		gbc_cmb_el.fill = GridBagConstraints.HORIZONTAL;
		gbc_cmb_el.insets = new Insets(0, 0, 5, 5);
		gbc_cmb_el.gridx = 2;
		gbc_cmb_el.gridy = 5;
		panel.add(cmb_el, gbc_cmb_el);
		
		JComboBox cmb_el_state = new JComboBox();
		cmb_el_state.setModel(new DefaultComboBoxModel(new String[] {"졸업(예정)", "휴학", "중퇴", "", "", ""}));
		GridBagConstraints gbc_cmb_el_state = new GridBagConstraints();
		gbc_cmb_el_state.insets = new Insets(0, 0, 5, 5);
		gbc_cmb_el_state.fill = GridBagConstraints.HORIZONTAL;
		gbc_cmb_el_state.gridx = 4;
		gbc_cmb_el_state.gridy = 5;
		panel.add(cmb_el_state, gbc_cmb_el_state);
		
		JLabel lblNewLabel_1 = new JLabel("모집직종");
		GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
		gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_1.gridx = 1;
		gbc_lblNewLabel_1.gridy = 6;
		panel.add(lblNewLabel_1, gbc_lblNewLabel_1);
		
		JComboBox cmb_job_type = new JComboBox();
		cmb_job_type.setModel(new DefaultComboBoxModel(new String[] {"경영/사무", "마케팅/무역/유통", "영업/고객상담", "IT/인터넷", "연구개발/설계", "생산/제조", "전문/특수직", "디자인", "미디어"}));
		GridBagConstraints gbc_cmb_job_type = new GridBagConstraints();
		gbc_cmb_job_type.gridwidth = 2;
		gbc_cmb_job_type.insets = new Insets(0, 0, 5, 5);
		gbc_cmb_job_type.fill = GridBagConstraints.HORIZONTAL;
		gbc_cmb_job_type.gridx = 2;
		gbc_cmb_job_type.gridy = 6;
		panel.add(cmb_job_type, gbc_cmb_job_type);
		
		JLabel lblNewLabel_2 = new JLabel("근무지역");
		GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
		gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_2.gridx = 1;
		gbc_lblNewLabel_2.gridy = 7;
		panel.add(lblNewLabel_2, gbc_lblNewLabel_2);
		
		JComboBox cmb_area = new JComboBox();
		cmb_area.setModel(new DefaultComboBoxModel(new String[] {"전국", "서울", "경기", "인천", "대전", "세종", "충북", "충남", "광주", "전북", "전남", "대구", "울산", "부산", "경북", "경남", "강원", "제주"}));
		GridBagConstraints gbc_cmb_area = new GridBagConstraints();
		gbc_cmb_area.gridwidth = 2;
		gbc_cmb_area.insets = new Insets(0, 0, 5, 5);
		gbc_cmb_area.fill = GridBagConstraints.HORIZONTAL;
		gbc_cmb_area.gridx = 2;
		gbc_cmb_area.gridy = 7;
		panel.add(cmb_area, gbc_cmb_area);
		
		JLabel lblNewLabel_3 = new JLabel("고용형태");
		GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
		gbc_lblNewLabel_3.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_3.gridx = 1;
		gbc_lblNewLabel_3.gridy = 8;
		panel.add(lblNewLabel_3, gbc_lblNewLabel_3);
		
		JComboBox cmb_ept_no = new JComboBox();
		cmb_ept_no.setModel(new DefaultComboBoxModel(new String[] {"정규직", "계약직", "인턴직"}));
		GridBagConstraints gbc_cmb_ept_no = new GridBagConstraints();
		gbc_cmb_ept_no.gridwidth = 2;
		gbc_cmb_ept_no.insets = new Insets(0, 0, 5, 5);
		gbc_cmb_ept_no.fill = GridBagConstraints.HORIZONTAL;
		gbc_cmb_ept_no.gridx = 2;
		gbc_cmb_ept_no.gridy = 8;
		panel.add(cmb_ept_no, gbc_cmb_ept_no);
		
		JLabel lblNewLabel_5 = new JLabel("모집연봉");
		GridBagConstraints gbc_lblNewLabel_5 = new GridBagConstraints();
		gbc_lblNewLabel_5.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_5.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_5.gridx = 1;
		gbc_lblNewLabel_5.gridy = 9;
		panel.add(lblNewLabel_5, gbc_lblNewLabel_5);
		
		JComboBox cmb_salary = new JComboBox();
		cmb_salary.setModel(new DefaultComboBoxModel(new String[] {"회사내규", "면접협의", "직접입력"}));
		GridBagConstraints gbc_cmb_salary = new GridBagConstraints();
		gbc_cmb_salary.gridwidth = 2;
		gbc_cmb_salary.insets = new Insets(0, 0, 5, 5);
		gbc_cmb_salary.fill = GridBagConstraints.HORIZONTAL;
		gbc_cmb_salary.gridx = 2;
		gbc_cmb_salary.gridy = 9;
		panel.add(cmb_salary, gbc_cmb_salary);
		
		JLabel lblNewLabel_7 = new JLabel("모집일자");
		GridBagConstraints gbc_lblNewLabel_7 = new GridBagConstraints();
		gbc_lblNewLabel_7.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_7.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_7.gridx = 1;
		gbc_lblNewLabel_7.gridy = 10;
		panel.add(lblNewLabel_7, gbc_lblNewLabel_7);
		
		ac_start = new JTextField();
		GridBagConstraints gbc_ac_start = new GridBagConstraints();
		gbc_ac_start.gridwidth = 2;
		gbc_ac_start.insets = new Insets(0, 0, 5, 5);
		gbc_ac_start.fill = GridBagConstraints.HORIZONTAL;
		gbc_ac_start.gridx = 2;
		gbc_ac_start.gridy = 10;
		panel.add(ac_start, gbc_ac_start);
		ac_start.setColumns(10);
		
	
		
		JLabel lblNewLabel_9 = new JLabel("마감일자");
		GridBagConstraints gbc_lblNewLabel_9 = new GridBagConstraints();
		gbc_lblNewLabel_9.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_9.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_9.gridx = 1;
		gbc_lblNewLabel_9.gridy = 11;
		panel.add(lblNewLabel_9, gbc_lblNewLabel_9);
		
		ac_final = new JTextField();
		ac_final.setToolTipText("(ex.2020-03-09)");
		GridBagConstraints gbc_ac_final = new GridBagConstraints();
		gbc_ac_final.gridwidth = 2;
		gbc_ac_final.insets = new Insets(0, 0, 5, 5);
		gbc_ac_final.fill = GridBagConstraints.HORIZONTAL;
		gbc_ac_final.gridx = 2;
		gbc_ac_final.gridy = 11;
		panel.add(ac_final, gbc_ac_final);
		ac_final.setColumns(10);
		
		JLabel lblNewLabel_4 = new JLabel("기타모집내용");
		GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints();
		gbc_lblNewLabel_4.insets = new Insets(0, 0, 0, 5);
		gbc_lblNewLabel_4.gridx = 1;
		gbc_lblNewLabel_4.gridy = 12;
		panel.add(lblNewLabel_4, gbc_lblNewLabel_4);
		
		final JTextArea textArea_content = new JTextArea();
		GridBagConstraints gbc_textArea_content = new GridBagConstraints();
		gbc_textArea_content.gridwidth = 7;
		gbc_textArea_content.insets = new Insets(0, 0, 0, 5);
		gbc_textArea_content.fill = GridBagConstraints.BOTH;
		gbc_textArea_content.gridx = 2;
		gbc_textArea_content.gridy = 12;
		panel.add(textArea_content, gbc_textArea_content);
	

		
		JPanel panel_1 = new JPanel();
		add(panel_1, BorderLayout.SOUTH);
		
		JButton btnNewButton_1 = new JButton("등록");
		
		panel_1.add(btnNewButton_1);
		
		JButton btnNewButton = new JButton("취소");
		panel_1.add(btnNewButton);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				rightCard.show(right_area, "rightcard2");
				menu2AreaCard.show(menuArea2, "menuP");
			}
		});
		
		ac_typeC.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) 
			{
				
				cr_year1_text.setEditable(true);
				type=1;
			
				cr_year1_text.setVisible(true);
				label_4.setVisible(true);
			
				
				
			}
		});
		
		ac_type.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				type=0;

				cr_year1_text.setEditable(false);
			
			
				cr_year1_text.setVisible(false);
				label_4.setVisible(false);
		
			}
		});
		
		
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				av.setAcTitle(ac_text.getText());
				av.setCrNo(type);
				av.setAcEndDate(ac_final.getText());
				av.setAcStartDate(ac_start.getText());
				av.setAcContent(textArea_content.getText());
//				av.setAcSalay();
		
				
				
			}
		});
		
		setVisible(true);
		
	
	}
}
